<?php
/**
 * Created by PhpStorm.
 * User: ouxiaobao
 * Date: 17/2/18
 * Time: 12:04
 */
namespace app\worker\controller;

use think\worker\Server;

class Worker extends Server{

    protected $socket = 'http://0.0.0.0:2346';//服务器地址
    protected $processes = 1;//开启进程数量



    public function _initialize()
    {
        parent::_initialize();
        $this->SystemMessage = model('SystemMessage');
    }


    /**
     * 连接回调
     * @param $connection
     *
     */
    public function onConnect($connection)
    {
        $connection->send("链接成功");
//        var_dump($connection->id);
    }

    /**
     * 通信回调
     * @param $connection
     * @param $data
     */
    public function onMessage($connection,$data)
    {
        var_dump($data);
        $connection->send("已收到你的信息");
    }
}